﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System.Web.UI;
using ESF.General.MVP;
using System;
using ESF.General;

#endregion


namespace ESF.Web.Pages
{
	public class BaseUserControl<P> : UserControl, IBaseViewer
	{
		#region Presenter
		
		protected P _Presenter;
		
		#endregion
	
	
		#region Miembros de IBaseViewer

		public bool frmEnabled
		{
			set { Visible = value; }
		}


		public string frmInfoMsg
		{
			set { JS.AddWarning (Page, value); }
		}
		

		public string frmErrorMsg
		{
			set 
			{
				JS.AddWarning (Page, value); 
			}
		}
		
		
		public string frmWarnMsg
		{
			set 
			{
				JS.AddWarning (Page, value); 
			}
		}


		public string frmUserAlias { get { return (Page.User != null ? Page.User.Identity.Name : null); } }
		
		
		public string frmUserHostAddress
		{
			get { return Page.Request.UserHostAddress; }
		}


		public bool frmIsAuthenticated
		{
			get { return (Page.User != null ? Page.User.Identity.IsAuthenticated : false); }
		}
		
		
		public string frmApplicationCode
		{
			set { PageHelper.SetApplicationCode (Page, value); }
			get { return PageHelper.GetApplicationCode (Page); }
		}


		public string frmApplicationName
		{
			get { return PageHelper.GetApplicationName (Page); }
			set { PageHelper.SetApplicationName (Page, value); }
		}


		public int CurrentAdvance100 { set; get; }

		public string CurrentStepName { set; get; }

		#endregion
		
		
		#region Funciones
		
		public void ShowClearProgressDialog ()
		{
			
		}


		public void LogError (Exception pEx)
		{
			Log.Error (pEx);
			
			frmErrorMsg = pEx.Message;
		}


		public virtual void OnClear () {}


		public virtual void CloseApplication() { }
		
		#endregion
	}
}
